﻿using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using Zenject;

public class WeaponSelectUI : MonoBehaviour, IPointerEnterHandler
{
    public Weapon _weapon { get; private set; }
    [Header("头像")] [SerializeField] private Image avatarImage;

    [Inject] private GameManager _gameManager;

    /**
     * 初始化单元格、保存对应role数据
     */
    public void InitUI(Weapon weapon)
    {
        _weapon = weapon;
        avatarImage.sprite = Resources.Load<Sprite>(weapon.avatar);
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        UpdateWeaponInfoUI();
    }

    public void UpdateWeaponInfoUI()
    {
        WeaponSelectUIManager.Instance.UpdateWeaponInfoUI(_weapon);
    }

    public void SelectWeapon()
    {
        //记录当前选择的weapon
        _gameManager.currentWeaponsBaseData.Add(_weapon);
        //切换单独选择UI
        WeaponSelectUIManager.Instance.SwitchDifficultySelectUI();

        DifficultySelectUIManager.Instance.UpdateRoleWeaponInfoUI();
    }
}